import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import { Plugin as importToCDN } from 'vite-plugin-cdn-import'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    importToCDN({
      modules: [
        {
          name: 'react',
          var: 'React',
          path: 'https://unpkg.com/react@18.2.0/umd/react.production.min.js'
        },
        {
          name: 'echarts',
          var: 'echarts',
          path: 'https://unpkg.com/echarts@5.4.2'
        },
        {
          name: '@wangeditor/editor',
          var: 'wangEditor',
          path: 'https://unpkg.com/@wangeditor/editor@latest/dist/index.js',
          css: 'https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css'
        }
      ]
    })
  ],
  resolve: {
    // 配置路径别名
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  }
})
